<script setup>
import {ElMessage} from 'element-plus'
import { ref } from 'vue'
const user = ref({
  name: '',
  password: '',
  choose: '',
  city: '',
  value: false
})
const f = (type) => {
  switch (type){
    case 1: ElMessage.success('提交成功');break;
    case 0: ElMessage.error('提交失败');
  }
}
</script>

<template>
<h1>表单组件</h1>
  <el-form style="width: 500px;margin: 0 auto;" label-width="80">
    <el-form-item label="用户名">
      <el-input placeholder="请输入用户名" v-model="user.name"></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input placeholder="请输入密码" v-model="user.password" show-password></el-input>
    </el-form-item>
    <el-form-item label="性别">
      <el-radio-group v-model="user.choose">
        <el-radio-button label="男" value="1"></el-radio-button>
        <el-radio-button label="女" value="2"></el-radio-button>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="所在地">
      <el-select v-model="user.city" placeholder="请选择城市">
        <el-option label="北京" value="bj"></el-option>
        <el-option label="上海" value="sh"></el-option>
        <el-option label="广州" value="gz"></el-option>
        <el-option label="深圳" value="sz"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="管理员">
      <el-switch v-model="user.value"></el-switch>
    </el-form-item>
    <el-form-item>
      <el-button @click="f(1)" type="success">点我提交</el-button>
    </el-form-item>
  </el-form>
</template>

<style scoped>

</style>